package org.shushan.web.demo.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.shushan.framework.core.resp.Result;
import org.shushan.framework.web.base.CrudControllerV2;
import org.shushan.web.demo.entity.MongoTest;
import org.shushan.web.demo.request.ElasticTestPage;
import org.shushan.web.demo.request.MongoTestDto;
import org.shushan.web.demo.request.MongoTestPage;
import org.shushan.web.demo.response.MongoTestVo;
import org.shushan.web.demo.service.MongoTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * (TUser)控制层
 * @author zhigang.li
 * @email 2429967859@qq.com
 * @since 2023-09-16 22:25:41
 */
@RestController
@Tag(name = "MongoTestController", description = "MongoTestController")
@RequestMapping("mongoTest")
public class MongoTestController
        extends CrudControllerV2<MongoTestPage, MongoTestDto, MongoTestVo, Long, MongoTest, MongoTestService> {


    @Autowired
    MongoTemplate mongoTemplate;

    @Operation(summary = "testMongo",description = "分页查询1121" )
    @GetMapping(value = "testMongo")
    public Result<Boolean> testMongo(ElasticTestPage request) {
        List<String> ss = new ArrayList<>();
        Criteria base = new Criteria();
        Criteria criteria =
                Criteria.where("test").is("test");
        base.andOperator(criteria,Criteria.where("test").gt("test"), Criteria.where("mv").is("test"));
        base.andOperator(Criteria.where("m1111v").is("test"));
        mongoTemplate.find(Query.query(base), MongoTest.class);
        return Result.ok();
    }

}

